{% extends "tardis_portal/data_browsing_template.html" %}

{% block script %}
{# <script type="text/javascript"> #}
{#     $(document).ready(function() { #}
{#         $(".dataset_metadata_toggle").toggle( #}
{#         function(){ #}
{#             $(this).text("[Show]"); #}
{#             var href= $(this).attr("href"); #}
{#             $(href).hide(); #}
{#         }, #}
{#         function(){ #}
{#             $(this).text("[Hide]"); #}
{#             var href= $(this).attr("href"); #}
{#             $(href).show(); #}
{#         } #}
{#         ); #}
{#         $(".dataset_metadata_toggle").click(); #}
{#     }); #}
{# </script> #}
{% endblock %}

{% load experimentstats %}

{% block content %}

<div id="content">
  {% if user.is_authenticated %}
    <div class="post">
      <h1 class="title">My Experiments</h1>

      {% if experiments %}
        <strong>{{ experiments.count }}</strong> experiment{{ experiments.count|pluralize}}
      {% endif %}
      <br/>
      <br/>

      {% if experiments %}
        <table class="experiment-table">
      {% for experiment in experiments %}
      {% if experiment.public %}
      {%else %}
        <tr>
          <th>
        <a href="{{ experiment.get_absolute_url }}">{{ experiment.title }}</a>
          </th>
        </tr>
        <tr>
          <td>
        From <strong>{{experiment.institution_name}}</strong>,
        updated <strong>{{ experiment.update_time|date:"jS F Y" }}</strong>
          </td>
        </tr>
        <tr>
          <td class="experiment-table-stats">
        <strong>{{ experiment.dataset_set.all.count }}</strong>
        dataset{{ experiment.dataset_set.all.count|pluralize }},
        containing <strong>{{ experiment.id|experiment_file_count }}</strong>
        file{{ experiment.id|experiment_file_count|pluralize }}
                <br/>
        <br/>
          </td>
        </tr>
        {%endif %}
        {% endfor %}
    </table>

    {% else %}
      No experiments available at this time.
    {% endif %}

    </div> <!-- post -->

    <br/>
    <br/>
    <br/>

  {% endif %}

  <div class="post">
    <h1 class="title">Public Experiments</h1>

    {% if experiments %}
      <strong>{{ public_experiments.count }}</strong>
      public experiment{{ public_experiments.count|pluralize }}
    {% endif %}

    <br/>
    <br/>

    {% if public_experiments %}
      <table class="experiment-table">
    {% for public_experiment in public_experiments %}
      <tr>
        <th>
          <a href="{% url tardis.tardis_portal.views.view_experiment public_experiment.id %}">
        {{ public_experiment.title }}</a>
        </th>
      </tr>
      <tr>
        <td>From <strong>{{public_experiment.institution_name}}</strong>,
          updated <strong>{{ public_experiment.update_time|date:"jS F Y" }}</strong></td>
      </tr>
    <tr>
      <td class="experiment-table-stats"><strong>{{ public_experiment.dataset_set.all.count }}</strong>
        dataset{{ public_experiment.dataset_set.all.count|pluralize }},
        containing <strong>{{ public_experiment.id|experiment_file_count }}</strong>
        file{{ public_experiment.id|experiment_file_count|pluralize }}
        <br/>
        <br/>
      </tr>
    {% endfor %}
      </table>

      {% else %}
        No public experiments at the moment.
      {% endif %}

  </div> <!-- post -->
</div> <!-- content -->

{% endblock %}
